﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PersonalHealth.Data.Model;
using HealthManagement.Common;
using com.jwxcd.CommunityDriver;
using System.Threading;

namespace HealthManagement.Views
{
    /// <summary>
    /// UserPanel.xaml 的交互逻辑
    /// </summary>
    public partial class UserPanel : Page
    {
        MeasureUser user;
        public UserPanel(MeasureUser user)
        {
            InitializeComponent();
            this.user = user;
            this.DataContext = user;
            this.Loaded += new RoutedEventHandler(UserPanel_Loaded);

            this.btnStop.IsEnabledChanged += new DependencyPropertyChangedEventHandler(btnStop_IsEnabledChanged);
        }


        void UserPanel_Loaded(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = false;
        }

        void btnStop_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            pnlType.IsEnabled = !btnStop.IsEnabled;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Content = new MeterPanel();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = true;
            //pnlType.IsEnabled = false;
            contentBorder.Content = new BloodPressure(user,this);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = true;
            //pnlType.IsEnabled = false;
            contentBorder.Content = new BloodOximeter(user,this);
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = true;
            //pnlType.IsEnabled = false;
            contentBorder.Content = new BloodSugar(user,this);
        }

        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = true;
            //pnlType.IsEnabled = false;
            contentBorder.Content = new Temperature(user,this);
        }

        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            btnStop.IsEnabled = true;
            //pnlType.IsEnabled = false;
            contentBorder.Content = new ECG(user,this);
        }

        private void btnStop_Click(object sender, RoutedEventArgs e)
        {
            (contentBorder.Content as MeasureBase).MeasureBase_Unloaded(this,null);
            contentBorder.Content = null;
            
            btnStop.IsEnabled = false;
            //pnlType.IsEnabled = true;
        }

        
    }
}
